﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Collections;
using System.Web.UI.MobileControls;


public static class LocationBasedApplicationDAL
{
    //Hozzáad egy új felhasználói profilt az adatbázisba
    public static void CreateUserProfile(UserProfile _up)
    {
        LocationBasedApplicationDataModelDataContext dc =
            new LocationBasedApplicationDataModelDataContext(WebConfigurationManager.ConnectionStrings["ASPNETConnectionString"].ConnectionString);
        dc.UserProfiles.InsertOnSubmit(_up); dc.SubmitChanges();
    }

    //Lekéri egy adott nevű felhasználó profilját 
    public static UserProfile GetUser(string _name)
    {
        LocationBasedApplicationDataModelDataContext dc =
            new LocationBasedApplicationDataModelDataContext(WebConfigurationManager.ConnectionStrings["ASPNETConnectionString"].ConnectionString);
        var q = from p in dc.UserProfiles
                where p.UserItem.UserName == _name
                select p; return q.First<UserProfile>();
    }

    public static List<UserItem> GetAllUsers()
    {
        LocationBasedApplicationDataModelDataContext dc =
               new LocationBasedApplicationDataModelDataContext(WebConfigurationManager.ConnectionStrings["ASPNETConnectionString"].ConnectionString);
        var q = from p in dc.UserItems
                select p;
        return q.ToList();
    }



}
